﻿@using EmoneyWeiXinEntity
@using EmoneyWeiXinCommon
@{
    Layout = null;
    weixinUserEntity wxInfo = ViewBag.wxInfo as weixinUserEntity; 
}

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>转盘抽奖页</title>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
    <meta name="format-detection" content="telephone=no" />
    <meta name="format-detection" content="email=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
        <script type="text/javascript">
            (function (doc, win) {
                var docEl = doc.documentElement,
                    resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
                    recalc = function () {
                        var clientWidth = docEl.clientWidth < 768 ? docEl.clientWidth : 768;
                        if (!clientWidth) return; docEl.style.fontSize = 16 * (clientWidth / 320) + 'px';
                    }; recalc();
                if (!doc.addEventListener) return; win.addEventListener(resizeEvt, recalc, false);
            })(document, window);
    </script>
    <link href="@Url.Content("~/css/NineMonth/basic.css")?a=@(new Random().Next())" rel="stylesheet" />
    <script src="@Url.Content("~/js/jquery.js")"></script>
    <script src="@Url.Content("~/js/jQueryRotate.2.1.js")"></script>
    <script src="@Url.Content("~/js/jweixin-1.0.0.js")"></script>
    <script src="@Url.Content("~/js/WeiXinCommon2.js")?a=@(new Random().Next())"></script>
    <script type="text/javascript">
        (function($){
            var result;
            var avgAngle = 360 / 5;
            var isrotated = false;
            var openid='@ViewBag.openid';
        function GetRandomNum(Min, Max) {
            var Range = Max - Min;
            var Rand = Math.random();
            result = (Min + Math.round(Rand * Range));
            result=@ViewBag.Result;
            return result;
        }


            $(document).ready(function () {

                var rotateFunc = function (angle) {
                    $("#dial").rotate({
                        angle: 0,
                        animateTo: angle + 1800,
                        duration: 8000,
                        callback: function () {
                            submitResult();
                        }
                    });
                }

                var roll = function () {
                    if (!isrotated) {
                        var angle = 0;
                        var Rand_num = GetRandomNum(1, 5);
                        rotateFunc(avgAngle / 2 + (Rand_num - 1) * avgAngle);
                        isrotated = true;
                    }
                }


                $("#pointer").bind("click", roll);
            });
            document.onselectstart = new Function("event.returnValue=false;");
            document.oncontextmenu = new Function("event.returnValue=false;");

            function  submitResult(){
                $.ajax({
                    url:'@Url.Action("PlayedGame", "NineMonthActive")',
                data:{openid:openid,result:result},
                type:'post',
                success:function(data)
                {
                    if(data=="1"){ //如果正确，则进行跳转
                        window.location.href="@Url.Action("ResultPage", "NineMonthActive")?openid="+openid;
                    }else
                        if(data=="3"){
                            alert("该openid是非法的！");
                        }
                }
                
            });
        }
        })(jQuery)


        
        //当执行分享动作的时候执行
        function sharaEvent(type) {
            $.ajax({
                url: '@Url.Action("ShareAct", "NineMonthActive")',
                    type: 'post',
                    data: { openid: '@ViewBag.openid', sharaType: type },
                    success: function (data) {
                   
                    }
                });
            }
    </script>
</head>
<body onload="rize()" onresize="rize()">
    <div class="box_A">
         <p class="box_A_bg" style="background:url(@Url.Content("~/images/NineMonth/bg01.png"))  no-repeat center">
        </p>
        <div class="content">
            <div id="lottery">
                <p id="dial">
                    <img src="@Url.Content("~/images/NineMonth/dial.png")" />
                </p>
                <p id="pointer">
                    <img src="@Url.Content("~/images/NineMonth/pointer.png")" />
                </p>
            </div>
            <p class="intro">
                <img src="@Url.Content("~/images/NineMonth/intro.png")">
            </p>
            <p class="seal"> 
                <img src="@Url.Content("~/images/NineMonth//seal.png")">
            </p>
        </div>
    </div>
</body>
<script>
    function rize() {
        var height = document.documentElement.clientHeight;
        $("body").css({ "height": height });
        $(".box_A").css({ "height": height });

    }
</script>

</html>

@*  关于微信分享部分的代码*@
<script type="text/javascript">
    var AppId = "@wxInfo.AppId";
    var AppSercret = "@wxInfo.AppSecret";
    var shareUrl = "@System.Configuration.ConfigurationManager.AppSettings["jyhdwzUrl"]";
    var timestamp = "@ViewBag.timestamp";
    var imgUrl = "@Config.Host_Url3" + "images/NineMonth/" + "shareImg.png";
    var tTitle = "看哭了，童年的记忆，每张图都戳中泪点";
    var tContent = "好棒的文章，深度戳泪，回忆泛滥。还能玩转盘，赢得大礼。快来跟我一起回忆吧！";
    var nonceStr = "@ViewBag.nonceStr";
    var signature = "@ViewBag.signature";
    ///初始化分享到朋友圈的功能
    function initSharePara() {
        mysharetime(shareUrl, imgUrl, tTitle, tContent, AppId, timestamp, nonceStr, signature, sharaEvent);
    }
    initSharePara();

</script>
